package demo17;

import java.util.*;

public class demo17_2 {
    public static void main(String[] args) {
        List<String> data = new ArrayList<>();
        String[] selects = {"A", "B", "C", "D"};
        Random r = new Random();
        for (int i = 0; i < 80; i++){
            data.add(selects[r.nextInt(4)]);
        }
        System.out.println(data);

        //统计学生选的情况
        Map<String, Integer> map = new HashMap<>();
        for (String datum : data) {
            if (map.containsKey(datum)){
                map.put(datum, map.get(datum) + 1);
            }
            else {
                map.put(datum, 1);
            }
        }
        System.out.println(map);
    }
}
